<template>
	<view class="content">
		<view class="loading">

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onLoad() {
			this.getCode()
		},
		methods: {
			/* getCode() {
				const url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' +
					'appid=wxd1f11eba5635d9d7' +
					'&redirect_uri=' + encodeURIComponent('http://youyu.v2code.cn/pages/loginbefore/loginbefore') +
					'&response_type=code' +
					'&scope=snsapi_userinfo' +
					'&state=STATE&connect_redirect=1#wechat_redirect';
				location.href = url
			}, */
			getCode() {
				if (uni.getStorageSync('isLogin')) {
					setTimeout(() => {
						uni.navigateTo({
							url: '../login/login'
						})
					}, 2000)
				} else {
					uniCloud.callFunction({
						name: 'zhuce'
					}).then(res => {
						console.log('注册完成', res)
						uni.setStorageSync('userInfo', res.result.data[0])
						uni.setStorageSync('isLogin', 1)
						uni.setStorageSync('openid', res.result.data[0]._id)
						setTimeout(() => {
							uni.navigateTo({
								url: '../login/login'
							})
						}, 2000)

					})


				}
			}

		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: url('@/static/bg.jpg') no-repeat center top;
		background-size: 100% auto;
	}

	.loading {
		width: 750rpx;
		height: 1252rpx;
		background: url('@/static/loading.gif') no-repeat center center;
		background-size: 100% auto;
		margin-top: 136rpx;
	}
</style>
